<template>
  <view>
    <view class="message-item" v-for="(item, index) in dataList" :key="index">
      <view class="top-box">
        <view class="top-left">
          <uni-icons type="sound-filled" color="#115BAA" size="18"></uni-icons>
          <view class="type">{{ item.noticeType || '订单通知' }}</view>
        </view>
        <view class="time">{{ item.createTime }}</view>
      </view>
      <view class="title">{{ item.title }}</view>
      <view class="content">{{ item.content }}</view>
      <view class="bottom-box" @click="clickDetail(item)">
        <view class="btn-text">查看详情</view>
        <uni-icons type="right" size="12" color="#999"></uni-icons>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name: 'MessageList',
    data() {
      return {
        dataList: []
      }
    },
    props: {
      messageList: {
        type: Array,
        default: []
      }
    },
    watch: {
      messageList: {
        handler(newVal, oldVal) {
          this.dataList = uni.$u.deepClone(newVal)
        },
        deep: true
      }
    },
    created() {
      this.dataList = uni.$u.deepClone(this.messageList)
    },
    methods: {
      clickDetail(item) {
        uni.navigateTo({
          url: `/subPages/physicianTrainPlan/patient/patientDetail?medicineId=${item.medicineId}`
        })
      }
    }
  }
</script>
<style lang="scss">
  .message-item {
    margin: 0 30rpx 30rpx;
    padding: 30rpx 30rpx 6rpx;
    border-radius: 16rpx;
    background-color: #FFF;
    .top-box {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .top-left {
        flex: 1;
        display: flex;
        align-items: center;
        .type {
          margin-left: 10rpx;
          font-size: 24rpx;
        }
      }
      .time {
        font-size: 24rpx;
        color: #999;
      }
    }
    .title {
      margin: 14rpx 0 20rpx;
      font-size: 32rpx;
      font-weight: 500;
    }
    .content {
      font-size: 24rpx;
      font-weight: 500;
      line-height: 36rpx;
      color: #999;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-line-clamp: 2; /* 控制显示的行数 */
    }
    .bottom-box {
      height: 60rpx;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 30rpx;
      border-top: 2rpx solid #EEE;
      .btn-text {
        font-size: 24rpx;
        color: #999;
      }
    }
  }
</style>
